<!--
 * @Date: 2019-07-24 19:30:04
 * @LastEditors: wangsh
 * @Author: wangsh
 -->
<template>
  <ms-dialog :title="title" width="30%" :dialog-visible="dialogVisible" @show="showDialog" @ok="handleSaveForm" @close="$emit('close')">
    <el-form v-loading="loading" ref="formValid" :rules="rules" :model="form" label-width="80px">
      <el-form-item label="字典值" prop="dictValue">
        <el-input v-model="form.dictValue" />
      </el-form-item>
      <el-form-item label="字典码" prop="code">
        <el-input v-model="form.code" />
      </el-form-item>
      <el-form-item label="排序">
        <el-input v-model="form.dictOrder" />
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="form.remark" />
      </el-form-item>
    </el-form>
  </ms-dialog>
</template>

<script>
import MsDialog from '@/common/dialog'
import tip from '@/mixins/tip'
const prefixUrl = '/sys/dict/'
export default {
  components: {
    MsDialog
  },
  mixins: [tip],
  data() {
    return {
      apiUrl: {
        get: `${prefixUrl}getById`,
        save: `${prefixUrl}saveDict`
      },
      rules: {
        dictValue: [
          { required: true, message: '请输入字典值', trigger: 'blur' }
        ],
        code: [
          { required: true, message: '请输入字典码', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    beforeSaveForm() {
      this.form.bookType = this.$parent.dictType
    }
  }
}
</script>
